#ifndef _T_DOUBLE_BUFFER_GL_H_
#define _T_DOUBLE_BUFFER_GL_H_

template <class T>
class T_DoubleBuffer_GL : public I_DoubleBuffer
{
public:
	T_DoubleBuffer_GL(void){}

	virtual ~T_DoubleBuffer_GL(void) 
	{
		Release();

		delete m_buffer[m_read];  m_buffer[m_read] = NULL;
		delete m_buffer[m_write]; m_buffer[m_write] = NULL;
	};

	virtual int SizeInBytes(void) { return m_size * sizeof(T); }


	virtual	void				CreateR(int nSize, I_Buffer * pShared)
	{
		if (m_buffer[m_read] == NULL) m_buffer[m_read]= new T_Buffer_GL<T>();
		m_buffer[m_read]->Create(nSize, pShared);
	}

	virtual	void				CreateW(int nSize, I_Buffer * pShared)
	{
		if (m_buffer[m_write] == NULL) m_buffer[m_write] = new T_Buffer_GL<T>();
		m_buffer[m_write]->Create(nSize, pShared);
	}

	virtual void				CreateR(int nSize, I_api_Device * pDevice = NULL)
	{
		if (m_buffer[m_read] == NULL) m_buffer[m_read]= new T_Buffer_GL<T>();
		m_buffer[m_read]->Create(nSize, pDevice);
	}

	virtual void				CreateW(int nSize, I_api_Device * pDevice = NULL)
	{
		if (m_buffer[m_write] == NULL) m_buffer[m_write] = new T_Buffer_GL<T>();
		m_buffer[m_write]->Create(nSize, pDevice);
	}
};

#endif